########################################################
# Part of MILIM NIRDAFOT project.
# Written by H. Magal, 2014
# See details on the project at the site:
#   https://sites.google.com/site/nirdafotdownloads/home
########################################################

# if you change version - you must also change it at 'nirdafot.xml' and upload TAR file
# and XML file to the google sites simultanously !!!!
__version__ = '1.02'                ### ENGINE VERSION IS DEFINED HERE ###
N = 6                               # number of words in a row
splitparts = 9                      # number of splits of windows-ZIP file
win_splits_extension = '.z'
__DBversion__ = None

import sys
import os

# This function sets some global symbols which have to be defined according to the underlying plaform (Windows/Linux)
# It returns True if platform was detected. It returns False if platform cannot be detected.
def set_platform_dependent_vars():
    global path_4_data_files
    global platform_is_Win
    global Win_uses_1folder
    platform_is_Win = False
    Win_uses_1folder = False
    path_4_data_files = ''
    platform = sys.platform

    # Check if nirdafot.debug exists. If exists, read it and replace some values
    # with debug values inside the file.
    debug_file = 'nirdafot.debug'
    if os.path.isfile (debug_file):
        dfile = open (debug_file, 'r')
        dengine = 'engineVersion='
        ddataBase = 'dataBaseVersion='
        while True:
            dline = dfile.readline ()
            if len (dline) == 0: break                                      # break on EOF
            sline = dline.rstrip ('\n\r')                                   # remove any trailing NL chars
            if sline.startswith (dengine) is True:
                global __version__
                __version__ = sline.replace (dengine, '')                   # remove leading string and leave only the '1.99' version string
            if sline.startswith (ddataBase) is True:
                global __DBversion__
                __DBversion__ = sline.replace (ddataBase, '')               # remove leading string and leave only the '1.99' version string
    # end of debug code section

    if platform.startswith ('linux'):
        path_4_data_files = './'
        return True
    if platform.startswith ('win'):
        platform_is_Win = True
        if sys.executable.endswith ('nirdafot.exe'):
            path_4_data_files = os.path.dirname (sys.executable) + '\\'     # It gives the path to nirdafot.exe file !
            Win_uses_1folder = True
        else:                                                               # If windows user chooses to work like Linux
            path_4_data_files = '.\\'                                       # (with full Python installation),
            #                                                               # then the data files are held at local folder
        return True
    return False                                                            # platform cannot be detected.